home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE16 / CLINIC / RUNAPPU.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-10-02  |  1.3 KB  |  65 lines

  1. unit RunAppU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Edit1: TEdit;
  12.     Edit2: TEdit;
  13.     Label1: TLabel;
  14.     Label2: TLabel;
  15.     Button1: TButton;
  16.     Button2: TButton;
  17.     procedure Button1Click(Sender: TObject);
  18.     procedure Button2Click(Sender: TObject);
  19.   public
  20.     procedure ThreadTerminate(Sender: TObject);
  21.   end;
  22.  
  23. var
  24.   Form1: TForm1;
  25.  
  26. implementation
  27.  
  28. uses
  29.   RunWaitU;
  30.  
  31. {$R *.DFM}
  32.  
  33. procedure TForm1.ThreadTerminate(Sender: TObject);
  34. begin
  35.   Button1.Enabled := True
  36. end;
  37.  
  38. procedure TForm1.Button1Click(Sender: TObject);
  39. begin
  40.   { This is the one that uses a thread. The button }
  41.   { normally gets re-enabled in the thread's OnTerminate }
  42.   { event handler. If there's a problem, we'll do it here }
  43.   Button1.Enabled := False;
  44.   try
  45.     WaitForApp(ExecApp(Edit1.Text, Edit2.Text), ThreadTerminate);
  46.   except
  47.     Button1.Enabled := True;
  48.     raise
  49.   end
  50. end;
  51.  
  52. procedure TForm1.Button2Click(Sender: TObject);
  53. begin
  54.   { This one doesn't use a thread, so we'll }
  55.   { make sure we re-enable the button here }
  56.   Button2.Enabled := False;
  57.   try
  58.     WaitForApp2(ExecApp2(Edit1.Text, Edit2.Text));
  59.   finally
  60.     Button2.Enabled := True
  61.   end
  62. end;
  63.  
  64. end.
  65.